<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class main extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('main_model');
    }
    
public function index()
    {
    $blogdata=$this->main_model->get_blog_data();
    
    if ($this->session->userdata('id')==NULL ){

        $dados = array(
                //carrega views
                'header' => 'header.php',
                'divheader' => 'divheader_notlogged.php',
                'divleftmenu' => 'divleftmenu_notlogged.php',
                'divcontent' => 'divcontent.php',
                'divfooter' => 'divfooter.php',
                'blogdata' => $blogdata,
            );
        $this->load->view('main', $dados);
        return;
        }
    
    if ($this->session->userdata('id')!=NULL){
        
        $dados = array(
                //carrega views
                'header' => 'header.php',
                'divheader' => 'divheader.php',
                'divcontent' => 'divcontent.php',
                'divleftmenu' => 'divleftmenu.php',
                'divfooter' => 'divfooter.php',
                'blogdata' => $blogdata,
                'perfil' => retornaperfil($this->session->userdata('user_role')),
                'menu_item' => criamenu($this->session->userdata('id'),$this->session->userdata('user_role')),
                );
        $this->load->view('main', $dados);
        }
    }
    
    public function logout(){
        
        $this->session->sess_destroy();
        redirect('main');
    }
}

/* End of file main.php */
/* Location: ./application/controllers/main.php */